/**********************************************************************
*
*   Copyright(C) 2021
*   FileName:
*   Version : V0.0.1
*   Date    : 2024-04-20
*   Author  : Song.YuLong@chipsbank
*   Description:
*
*   Others:
*
*   Function List:
*   History      :
*
***********************************************************************/

#ifndef __LCD_DRAW_H__
#define __LCD_DRAW_H__


#include "app_config.h"
#include "Type_def.h"

#include "lcd_driver_i2c.h"
#include "lcd_driver_spi.h"

enum {
    E_DRAW_FB = 0,  /* Draw到显存FrameBuffer：需要调用update接口才会显示到屏幕 */
    E_DRAW_SC,      /* Draw到屏幕Screen:立即显示到屏幕 */
};

enum {
    E_DRAW_0 = 0,   /* Draw 点 0 */
    E_DRAW_1 = 1,   /* Draw 点 1 */
};

enum {
    E_DRAW_NORMAL = 0,  /* 正常 */
    E_DRAW_INVERSE = 1, /* 反色 */
};

/**
 * @brief 	清除屏幕
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_clear(uint8_t draw_mode);

/**
 * @brief 	清除屏幕
 * @param 	dot : 点的颜色值 1 或 0
 * @param 	draw_mode: E_LCD_DRAW_FB draw到FB
 * 					   E_LCD_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_fill(uint8_t dot, uint8_t draw_mode);

/**
 * @brief 	画点
 * @param 	x: X坐标 
 * @param  	y: Y坐标
 * @param 	dot: 1 or 0
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_dot(int x, int y, uint8_t dot, uint8_t draw_mode);

/**
 * @brief 	画横线
 * @param 	x: X坐标 
 * @param  	y: Y坐标
 * @param 	dot: 1 or 0
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_hline(int x0, int y0, int width, uint8_t dot, uint8_t draw_mode);

/**
 * @brief 	画竖线
 * @param 	x: X坐标 
 * @param  	y: Y坐标
 * @param 	dot: 1 or 0
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_vline(int x0, int y0,  int height, uint8_t dot, uint8_t draw_mode);

/**
 * @brief	画线
 * @param	x1: 起点x坐标
 * @param	y1: 起点y坐标
 * @param 	x2: 终点x坐标
 * @param 	y2: 终点y坐标
 * @param	color: 颜色 0 or 1
 * @param	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_line(int x1, int y1, int x2, int y2, uint8_t color, uint8_t draw_mode);

/**
 * @brief 	空心矩阵
 * @param 	x: X坐标 
 * @param  	y: Y坐标
 * @param 	dot: 1 or 0
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_rect(int x, int y, int width, int height, uint8_t dot, uint8_t draw_mode);

/**
 * @brief 	填充矩阵
 * @param 	x: X坐标 
 * @param  	y: Y坐标
 * @param 	dot: 1 or 0
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_fill_rect(int x, int y, int width, int height, uint8_t dot, uint8_t draw_mode);


/*
 @brief 画空心圆
 @param x0 ：圆心X坐标
 @param y0 ：圆心Y坐标
 @param r  ：圆半径
 @param color ：颜色
 @param draw_mode ：E_DRAW_FB draw到FB
 				   E_DRAW_SC draw到SC
*/
void lcd_draw_circle(int x0, int y0, uint8_t r, uint8_t dot, uint8_t draw_mode);

/**
 * @brief 	将bmp_buf图像数据写入到FB的制定区域
 * @param 	x:原点x坐标
 * @param 	y:原点y坐标 
 * @param 	xSize:图像宽度
 * @param 	ySize:图像高度
 * @param 	bmp_buf:单色点阵图像数据
 * @param	inverse:颜色 1:反色，0:正常
 * @param 	draw_mode: E_DRAW_FB draw到FB
 * 					   E_DRAW_SC draw到SC
 * @return 	none
*/
void lcd_draw_buf(int x, int y, int width, int height, uint8_t *bmp_buf, uint8_t inverse, uint8_t draw_mode);


/**
 * @brief	更新屏幕数据，将FB数据写入到屏GRAM显示
 * @param 	none
 * @return 	none
*/
void lcd_draw_update(void);

/**
 * @brief	LCD背光控制
 * @param	state: 1,背光亮，0,背光灭
 * @return	void
 * @note	
*/
void lcd_backlight_control(u8 state);


void lcd_draw_init(void);

#endif